#!/usr/bin/perl

$numcells=0;

$maxx=$ARGV[0];
$maxy=$ARGV[1];
$numsusceptible=$ARGV[2];

@launched = ();
$numcells=0;

for($i=0; $i<$numsusceptible;) {
	$x=int($maxx * rand());
	$y=int($maxy * rand());
	if($launched[$y*100 + $x] == 0) {
		system("java -cp \"lib/java-getopt-1.0.13.jar;build\" assg.funnycells.cells.FunnyCell -x$x -y$y -t0 -icell$numcells -l0 &");
		$launched[$y*100 + $x]++;
		$numcells++;
		$i++;
	}
}

for($i=1; $i<$maxy; $i+=3) {
	$cellid=$numcells + ($i - 1)/3;
	system("java -cp \"lib/java-getopt-1.0.13.jar;build\" assg.funnycells.cells.FunnyCell -x0 -y$i -t1 -icell$cellid -l2 &");
	system("echo \"launched for $i\"");
}



